import com.fz.entity.Book;

import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Date;

/**
 * Created by webrx on 2017-09-09.
 */

public class Demo {
@Test
    public  void aa(){
        //下面是建立bean工厂的两种方式
        //BeanFactory f=new ClassPathXmlApplicationContext("b*.xml");
        //这种建立工厂的方式适合多人开发，在applicationContext.xml中引入多个beans.xml自动合成
        BeanFactory f=new ClassPathXmlApplicationContext("applicationContext.xml");
        System.out.println(f);
        Date d=f.getBean(Date.class);
        System.out.println(d);//Sat Sep 09 10:18:48 CST 2017
        System.out.println(d.toLocaleString());//转为习惯的标准格式：2017-9-9 10:18:48
        Date d1=f.getBean("d",Date.class);
        System.out.println(d==d1);//true;
        System.out.println(d1.toLocaleString());
        System.out.println("-------------------");
        Book b=f.getBean(Book.class);
        b.setId(10);
        b.setName("余壮壮");
        System.out.println(b);

        System.out.println("-----------");
        Book b1=f.getBean("/user/Book",Book.class);

        b1.setId(10);
        b1.setName("余壮壮");
        System.out.println(b1);
        System.out.println(b==b1);
    }
}
